package it.geosolutions.geoserver.rest.vgis;

/**
 * @author chenxw
 * @version 1.0
 * @date 2022/2/15 15:32
 * geoserver服务发布测试类
 */
public class publisherTest {
    public static void main(String[] args){

//        String shpzipPath="E:\\data\\vector_gzqxj.zip";
        String shpzipPath="E:\\data\\gzdsj_84.zip";
        String tifPath = "E:\\data\\TW2015.tif";
        String jpgzipPath="E:\\data\\TW_2021_DDZD1_0.5.zip";
        String pngzipPath="E:\\data\\TW_2018_DDZD1_0.5.zip";
        String imgPath="E:\\data\\TW_2021_DDZD1_0.5.img";
        String enviFilePath="E:\\data\\hdr\\TW_2018_DDZD1_0.5.dat";
//        String imgPath="E:\\data\\TW_2018_DDZD1_0.5.img";  这个不行，geoserver自动发布不能识别投影
        String geoserverHost = "192.168.3.77";
        String geoserverPort = "8085";
        String geoserverUserName = "admin";
        String geoserverPassWord = "geoserver";
        String geoserverWorkspace = "ttxm";
        String pointShpPublishStyleName="ttxm:redpt";
        String lineShpPublishStyleName="ttxm:blueln";
        String polygonShpPublishStyleName="ttxm:greenpoly";

//        //shp数据发布
//        String publishResult = GeoServerUtil.publishShpService(shpzipPath, geoserverHost,
//                geoserverPort,
//                geoserverUserName, geoserverPassWord, geoserverWorkspace,pointShpPublishStyleName,
//                lineShpPublishStyleName,polygonShpPublishStyleName);
//        if (publishResult != null) {
//            System.out.println("shp矢量服务发布成功："+publishResult);
//        }
//        else{
//            System.out.println("shp矢量服务发布失败");
//        }

//        //tif数据发布
//        String publishResult1 = GeoServerUtil.publishTifService(tifPath, geoserverHost,
//                geoserverPort,
//                geoserverUserName, geoserverPassWord, geoserverWorkspace);
//        if (publishResult1 != null) {
//            System.out.println("tif影像服务发布成功："+publishResult1);
//        }
//        else{
//            System.out.println("tif影像服务发布失败");
//        }
//
//        //erdas img数据发布
//        String publishResult2 = GeoServerUtil.publishImgService(imgPath, geoserverHost,
//                geoserverPort,
//                geoserverUserName, geoserverPassWord, geoserverWorkspace);
//        if (publishResult2 != null) {
//            System.out.println("img影像服务发布成功："+publishResult2);
//        }
//        else{
//            System.out.println("img影像服务发布失败");
//        }


//
//        //jpg数据发布
//        String publishResult3 = GeoServerUtil.publishJpgService(jpgzipPath, geoserverHost,
//                geoserverPort,
//                geoserverUserName, geoserverPassWord, geoserverWorkspace);
//        if (publishResult3 != null) {
//            System.out.println("jpg影像服务发布成功："+publishResult3);
//        }
//        else{
//            System.out.println("jpg影像服务发布失败");
//        }

        //envi 数据发布
        //还有问题，手工发布成功，但程序自动发布失败：提示不能识别的类型ERROR 4: `F:\geoserver-2.19.3-bin\data_dir\data\ttxm\TW_2018_DDZD1_0
        // .5_1648002810615\TW_2018_DDZD1_0.5_1648002810615.envihdr' not recognized as a supported file format.
//        String publishResult4 = GeoServerUtil.publishEnviService(enviFilePath, geoserverHost,
//                geoserverPort,
//                geoserverUserName, geoserverPassWord, geoserverWorkspace);
//        if (publishResult4 != null) {
//            System.out.println("envi影像服务发布成功："+publishResult4);
//        }
//        else{
//            System.out.println("envi影像服务发布失败");
//        }


        //
        //png数据发布
        String publishResult5 = GeoServerUtil.publishPngService(pngzipPath, geoserverHost,
                geoserverPort,
                geoserverUserName, geoserverPassWord, geoserverWorkspace);
        if (publishResult5 != null) {
            System.out.println("png影像服务发布成功："+publishResult5);
        }
        else{
            System.out.println("png影像服务发布失败");
        }


    }



}
